<template>
	<view class="page_box">
		<view class="head_box " v-if="0">
			<yy-custom bgColor="bg-gradual-blue">
				<block slot="backText">返回</block>
				<block slot="content">导航栏</block>
			</yy-custom>
		</view>

		<view class="content_box   ">
			<view class="head padding-lr bg-white flex align-center justify-between text-black margin-bottom">
				<text class="f28">
					总人数：
					<text>{{ total }}</text>
				</text>
				<view class="" @click="show = true">
					<text class="f28">筛选</text>
					<text class="cuIcon-filter margin-left-xs"></text>
				</view>
			</view>
			<scroll-view scroll-y="true" class="scroll" @scrolltolower="lower" enable-flex="true">
				<view
					class="info padding flex margin-bottom justify-between align-center"
					v-for="(item, index) in data"
					:key="index"
				>
					<view class=" flex">
						<image
							:src="item.user.headimgurl"
							mode="aspectFill"
							style="width: 120rpx ; height: 120rpx;"
							class="round"
						></image>
						<view class="flex flex-direction margin-left justify-around">
							<view class="flex align-center  ">
								<text class="f30 text-light">{{ item.user.nickname }}</text>
								<view class="gg flex align-center justify-center margin-left">
									<text
										class="cuIcon-favorfill margin-right-xs"
										style="color: #fbb03b;"
									></text>
									<text class="f26 text-white">{{ item.user.level }}</text>
								</view>
							</view>
							<text class="f24 text-gray">{{ item.user.modifyDt }}</text>
						</view>
					</view>
					<view class="margin-right" style="color: #FBB03B;" v-if="item.record.inviterId != id && item.record.super_id != id">
						越级
					</view>
				</view>
			</scroll-view>
		</view>
		<u-action-sheet :list="list" v-model="show" @click="click"></u-action-sheet>
		<view class="foot_box"></view>
		<!-- 登录提示 -->
		<yy-login v-if="false"></yy-login>
		<!-- 加载提示 -->
		<yy-loading text="加载中.." mask="true" click="true" ref="loading"></yy-loading>
		<!-- 信息提示-->
		<u-toast ref="uToast" />
	</view>
</template>

<script>
export default {
	components: {},
	data() {
		return {
			show: false,
			data: [],
			total: '',
			type: '',
			id: uni.getStorageSync('data').id,
			page: 1,
			list: [
				{
					text: '不 限'
				},
				{
					text: '等级 A'
				},
				{
					text: '等级 B'
				},
				{
					text: '等级 C'
				}
			]
		};
	},
	onShow() {},
	onLoad(e) {
		this.getRecords();
	},

	methods: {
		lower() {
			console.log('111 :>> ', 111);
			this.page++;
			this.getRecords();
		},
		async getRecords() {
			let obj = {
				sourceUserId: uni.getStorageSync('data').id,
				page: this.page,
				type: this.type
			};
			const res = await this.$u.get('/inviterrecord/myRecord', obj, {});
			if (res.code == 0) {
				this.data = res.data.records;
				this.total = res.data.total;
				if (this.data.length == 0) {
					this.$refs.uToast.show({ title: '暂无此筛选邀请记录', type: 'error' });
				}
			}
			//this.data = res.data;
			// this.$refs.uToast.show({ title: res.msg, type: 'success' });
		},
		jump(url) {
			console.log('url: ', url);
			uni.navigateTo({
				url
			});
		},
		click(index) {
			switch (index) {
				case 0:
					this.type = '';
					this.getRecords();
					break;
				case 1:
					this.type = 'A';
					this.getRecords('A');
					break;
				case 2:
					this.type = 'B';
					this.getRecords('B');
					break;
				case 3:
					this.type = 'C';
					this.getRecords('C');
					break;
				default:
					break;
			}

			console.log(`点击了第${index}项，内容为：${this.list[index].text}`);
		}
	}
};
</script>

<style lang="scss" scoped>
.page_box {
	background-color: #f7f7f7;
	.scroll {
		height: calc(100vh - 200rpx);
	}
	.content_box {
		.head {
			width: 100vw;
			height: 100rpx;
		}
		.info {
			width: 750rpx;
			height: 180rpx;
			background: #ffffff;
			.gg {
				width: 80rpx;
				height: 30rpx;
				background: linear-gradient(139deg, #393b56, #4f4f62);
				border-radius: 10rpx;
			}
		}
	}
}
</style>
